import 'dart:typed_data';
import '../../../../library.dart';
import '../../../base/message/private_instruction_message_base.dart';

// Lorin指令
abstract class LorinPrivateIntructionMessage<R extends LorinPrivateRequestBody>
    extends PrivateInstructionMessageBase<LorinMessage> {
  // 私有请求体
  R get privateRequestBody;

  @override
  LorinMessage getRealtimeInfoIntrMsg() =>
      LorinMessage.from(privateRequestBody.getRealtimeInfo());

  @override
  LorinMessage getRealtimeStatusIntrMsg() =>
      LorinMessage.from(privateRequestBody.getRealtimeStatus());

  @override
  LorinMessage getRealtimeErrorIntrMsg() =>
      LorinMessage.from(privateRequestBody.getRealtimeError());

  @override
  LorinMessage getRealtimeAllIntrMsg() =>
      LorinMessage.from(privateRequestBody.getRealtimeAll());

  @override
  LorinMessage getRealtimeBatteryInfoIntrMsg() =>
      LorinMessage.from(privateRequestBody.getRealtimeBatteryInfo());

  @override
  LorinMessage getStatisticOnceIntrMsg({int? startNum, int? count}) =>
      LorinMessage.from(privateRequestBody.getStatisticOnce(
        startNum: startNum,
        count: count,
      ));

  @override
  LorinMessage getStatisticsTotalIntrMsg() =>
      LorinMessage.from(privateRequestBody.getStatisticTotal());

  @override
  LorinMessage getSettingsAllIntrMsg() =>
      LorinMessage.from(privateRequestBody.getSettingsAll());

  @override
  LorinMessage setStandbyTimeIntrMsg(int time) {
    return LorinMessage.from(privateRequestBody.setStandyTime(time));
  }

  @override
  LorinMessage setRtcTimeIntrMsg(DateTime time) {
    return LorinMessage.from(privateRequestBody.setRtcTime(time));
  }

  @override
  LorinMessage lockIntrMsg(Uint8List identifyBytes, bool status) =>
      LorinMessage.from(privateRequestBody.lock(status));

  // 鸣笛
  @override
  LorinMessage hornIntrMsg() => LorinMessage.from(privateRequestBody.horn());

  @override
  LorinMessage playSoundIntrMsg(int audioIndex, {bool? play = true}) =>
      LorinMessage.from(privateRequestBody.playSound(audioIndex, play: play));

  // 开灯/关灯
  @override
  LorinMessage lightIntrMsg({required bool lowBeam, required bool highBeam}) =>
      LorinMessage.from(privateRequestBody.light(
        lowBeam: lowBeam,
        highBeam: highBeam,
      ));

  // 获取综合产品信息
  @override
  LorinMessage getIntegratedProductInfoIntrMsg() =>
      LorinMessage.from(privateRequestBody.getIntegratedProductInfo());

  // 获取综合实时信息
  @override
  LorinMessage getIntegratedRealtimeInfoAllIntrMsg() =>
      LorinMessage.from(privateRequestBody.getIntegratedRealtimeInfoAll());

  // 设置周期数据上报间隔
  @override
  LorinMessage setPeriodicDataReportingIntervalIntrMsg(int interval) {
    return LorinMessage.from(
        privateRequestBody.setPeriodicDataReportingInterval(interval));
  }

  // 车辆昵称
  @override
  LorinMessage getVehicleNicknameIntrMsg() {
    return LorinMessage.from(privateRequestBody.getVehicleNickname());
  }

  // 车辆昵称
  @override
  LorinMessage setVehicleNicknameIntrMsg(Uint8List bytes) {
    return LorinMessage.from(
        privateRequestBody.setVehicleNickname(nicknameBytes: bytes));
  }

  // 车辆密码
  @override
  LorinMessage getVehiclePasswordIntrMsg() {
    return LorinMessage.from(privateRequestBody.getVehiclePassword());
  }

  // 车辆密码
  @override
  LorinMessage setVehiclePasswordIntrMsg(Uint8List bytes) {
    return LorinMessage.from(
        privateRequestBody.setVehiclePassword(passwordBytes: bytes));
  }

  @override
  LorinMessage setRideModeIntrMsg(int mode) => LorinMessage.from(
        privateRequestBody.setRideMode(mode),
      );

  @override
  LorinMessage setSpeedLimitIntrMsg(int speed) =>
      LorinMessage.from(privateRequestBody.setSpeedLimit(speed));

  @override
  LorinMessage setWarningSpeedIntrMsg(int speed) =>
      LorinMessage.from(privateRequestBody.setWarningSpeed(speed));

  @override
  LorinMessage setRideAssistSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setRideAssistSwitch(enable));

  @override
  LorinMessage setAccAndBrakeAssistPercentageIntrMsg(
          {required int accPercentage, required int brakePercentage}) =>
      LorinMessage.from(privateRequestBody.setAccAndBrakeAssistPercentage(
          accPercentage, brakePercentage));

  @override
  LorinMessage setPedalSensitivityIntrMsg(int sensitivity1, int sensitivity2) =>
      LorinMessage.from(
          privateRequestBody.setPedalSensitivity(sensitivity1, sensitivity2));

  @override
  LorinMessage setBalanceAngleIntrMsg(int angle) =>
      LorinMessage.from(privateRequestBody.setBalanceAngle(angle));

  @override
  LorinMessage setBermAngleModeSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setBermAngleModeSwitch(enable));

  @override
  LorinMessage setSpinKillSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setSpinKillSwitch(enable));

  @override
  LorinMessage setMainSoundSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setMainSoundSwitch(enable));

  @override
  LorinMessage setVoiceSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setVoiceSwitch(enable));

  @override
  LorinMessage setVolumeIntrMsg(int volume) =>
      LorinMessage.from(privateRequestBody.setVolume(volume));

  @override
  LorinMessage setTBoxLowBatteryWakeupSwitchIntrMsg(bool enable) =>
      LorinMessage.from(
          privateRequestBody.setTBoxLowBatteryWakeupSwitch(enable));

  @override
  LorinMessage setTBoxRebootIntrMsg() =>
      LorinMessage.from(privateRequestBody.tBoxReboot());

  @override
  LorinMessage setTransportModeSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setTransportModeSwitch(enable));

  @override
  LorinMessage triggerVehicleCalibrationIntrMsg(
          {bool? gyroCalibrationEnabled,
          bool? pitchCalibrationEnabled,
          bool? rollCalibrationEnabled}) =>
      LorinMessage.from(privateRequestBody.triggerVehicleCalibration(
        gyroCalibrationEnabled: gyroCalibrationEnabled,
        pitchCalibrationEnabled: pitchCalibrationEnabled,
        rollCalibrationEnabled: rollCalibrationEnabled,
      ));

  @override
  LorinMessage setLoadDetectionIntrMsg() =>
      LorinMessage.from(privateRequestBody.triggerLoadDetection());

  @override
  LorinMessage setNoLoadDetectionIntrMsg() =>
      LorinMessage.from(privateRequestBody.triggerNoLoadDetection());

  @override
  LorinMessage setAutoHeadlightModeSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setAutoHeadlightModeSwitch(enable));

  @override
  LorinMessage setTurnSignalIntrMsg(bool leftSignal, bool rightSignal) =>
      LorinMessage.from(privateRequestBody.setTurnSignalLight(
        left: leftSignal,
        right: rightSignal,
      ));

  @override
  LorinMessage setLowBatteryRideSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setLowBatteryRideSwitch(enable));

  @override
  LorinMessage setDisplayAutoOffSwitchIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.setDisplayAutoOffSwitch(enable));

  @override
  LorinMessage setLogoLightBrightnessIntrMsg(int brightness) =>
      LorinMessage.from(privateRequestBody.setLogoLightBrightness(brightness));

  @override
  LorinMessage setDaytimeRunningLightSwitchIntrMsg(bool enable) =>
      LorinMessage.from(
          privateRequestBody.setDaytimeRunningLightSwitch(enable));

  @override
  LorinMessage getTirePressureSensorInfoIntrMsg() =>
      LorinMessage.from(privateRequestBody.getTirePressureSensorInfo());

  @override
  LorinMessage clearSearchedTirePressureSensorInfoIntrMsg() =>
      LorinMessage.from(
          privateRequestBody.clearSearchedTirePressureSensorInfo());

  @override
  LorinMessage setTirePressureLowAlarmThresholdIntrMsg(int threshold) =>
      LorinMessage.from(
          privateRequestBody.setTirePressureLowAlarmThreshold(threshold));

  @override
  LorinMessage setDisplayEnterUpgradeStatusIntrMsg(bool enable) =>
      LorinMessage.from(privateRequestBody.displayEnterUpgradeStatus(enable));

  @override
  LorinMessage setDisplayEnterFileTransferStatusIntrMsg(bool enable) =>
      LorinMessage.from(
          privateRequestBody.displayEnterFileTransferStatus(enable));

  @override
  LorinMessage clearMotorAdaptationDataIntrMsg() =>
      LorinMessage.from(privateRequestBody.clearMotorAdaptationData());

  @override
  LorinMessage getMotorAdaptationStatusIntrMsg() =>
      LorinMessage.from(privateRequestBody.getMotorAdaptationStatus());

  @override
  LorinMessage startBatteryVoltageCalibrationIntrMsg({bool? write = true}) =>
      LorinMessage.from(
          privateRequestBody.startBatteryVoltageCalibration(write: write));

  @override
  LorinMessage startMotorAdaptationIntrMsg() =>
      LorinMessage.from(privateRequestBody.startMotorAdaptation());

  @override
  LorinMessage startMotorSelfCheckIntrMsg({int? method = 1}) =>
      LorinMessage.from(privateRequestBody.startMotorSelfCheck(method: method));

  @override
  LorinMessage stopMotorAdaptationIntrMsg() =>
      LorinMessage.from(privateRequestBody.stopMotorAdaptation());

  @override
  LorinMessage writeActivationTimeIntrMsg(Uint8List time) =>
      throw UnimplementedError();

  @override
  LorinMessage getSnIntrMsg() => throw UnimplementedError();

  @override
  LorinMessage getProductModelIntrMsg() => throw UnimplementedError();

  @override
  LorinMessage writeProductModelIntrMsg(Uint8List model) =>
      throw UnimplementedError();

  @override
  LorinMessage getAuthRandomCodeIntrMsg(Uint8List identifierBytes) =>
      throw UnimplementedError();

  @override
  LorinMessage verifyAuthRandomCodeIntrMsg(Uint8List bytes) =>
      throw UnimplementedError();

  @override
  LorinMessage enablePeriodicDataSwitchIntrMsg(bool enable) =>
      throw UnimplementedError();

  // 读取控制器曲线
  LorinMessage getControllerDataIntrMsg(Uint8List addrBytes) =>
      throw UnimplementedError();

  // 设置控制器曲线
  LorinMessage setControllerDataIntrMsg(
          Uint8List addrBytes, Uint8List dataBytes) =>
      throw UnimplementedError();

  @override
  LorinMessage addMasterKeyIntrMsg(Uint8List bytes) =>
      throw UnimplementedError();

  @override
  LorinMessage deleteMasterKeyIntrMsg(Uint8List bytes) =>
      throw UnimplementedError();
  @override
  LorinMessage addSubKeyIntrMsg(Uint8List bytes) => throw UnimplementedError();

  @override
  LorinMessage deleteSubKeyIntrMsg(Uint8List bytes) =>
      throw UnimplementedError();

  @override
  LorinMessage getKeyListIntrMsg(Uint8List bytes) => throw UnimplementedError();

  @override
  LorinMessage deleteNfcCardIntrMsg() => throw UnimplementedError();

  @override
  LorinMessage enterNfcCardModeIntrMsg() => throw UnimplementedError();

  @override
  LorinMessage exitNfcCardModeIntrMsg() => throw UnimplementedError();

  @override
  LorinMessage setTBoxScreenInfoDisplaySwitchIntrMsg(bool enable) =>
      throw UnimplementedError();
}
